package app.auto.designer.func;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import java.util.List;

import app.auto.designer.R;
import app.auto.designer.ActivityBase;
import app.auto.designer.tool.StorageUtil;
import app.auto.runner.base.MapViewConf;
import app.auto.runner.base.action.Actions;
import app.auto.runner.base.action.BaseTask;
import app.auto.runner.base.ui.ExpandableView;

public class FuncListActivity extends ActivityBase {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_func_list);
        click(R.id.transparent, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        String layout = getIntent().getStringExtra("layout");
        String id = getIntent().getStringExtra("id");
        StorageUtil stg = new StorageUtil(StorageUtil.getLayoutPath(layout));
        String click = stg.getKeyedV(id+".onClick");
//        String onlongclick = stg.getKeyedV(id+".onClick");
        if(!TextUtils.isEmpty(click)){
//            List<String> clicks = Arrays.asList(click.split(";"));
            List<BaseTask> list = Actions.withView(getWindow().getDecorView()).parse(click).getBaseTasks();
            MapViewConf.with(getBaseContext()).source(list,getView(R.id.clicks)).conf(MapViewConf.with(getBaseContext()).source(R.layout.auto_string_item).pair("showParams->name")).toView();
        }
        click(R.id.addope, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(getBaseContext(), ExpActivity.class),0);
            }
        });

    }
}
